package pl.maciejziarko.mshare.dto.converters;

import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import pl.maciejziarko.mshare.domain.Account;
import pl.maciejziarko.mshare.dto.RegisterDTO;
import pl.maciejziarko.mshare.security.SaltGenerator;

import java.util.Date;

/**
 * @author Maciej Ziarko
 */
@Component
public final class RegisterDTOConverter {
    public RegisterDTOConverter() {
    }

    public Account convert(RegisterDTO formObject) {
        Account account = new Account(formObject.getUsername());
        account.setPassword(formObject.getPassword());
        account.setEmail(formObject.getEmail());
        account.setFirstName(formObject.getFirstName());
        account.setLastName(formObject.getLastName());
        return account;
    }

    public RegisterDTO convert(Account account) {
        RegisterDTO registerDTO = new RegisterDTO();
        registerDTO.setUsername(account.getUsername());
        registerDTO.setEmail(account.getEmail());
        registerDTO.setFirstName(account.getFirstName());
        registerDTO.setLastName(account.getLastName());
        return registerDTO;
    }
}
